<template>
  <br />
  <div id="components-affix-demo-target" ref="containerRef" class="scrollable-container">
    <div class="background">
      <z-affix :target="() => containerRef">
        <z-button type="primary">Fixed at the top of container</z-button>
      </z-affix>
    </div>
  </div>
</template>
<script>
import { defineComponent, ref } from 'vue'
export default defineComponent({
  setup() {
    const containerRef = ref()
    return {
      containerRef
    }
  }
})
</script>
<style>
#components-affix-demo-target.scrollable-container {
  height: 100px;
  overflow-y: scroll;
}
#components-affix-demo-target .background {
  padding-top: 60px;
  height: 300px;
  background-image: url('https://zos.alipayobjects.com/rmsportal/RmjwQiJorKyobvI.jpg');
}
</style>
